<template>
  <a-drawer
    v-model:visible="vdata.visible"
    title="进件信息"
    :body-style="{ paddingBottom: '80px' }"
    width="40%"
    @close="onClose"
  >
    <a-row justify="space-between" type="flex">
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="商户号">
            {{ vdata.detailData.mchNo }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="服务商号">
            {{ vdata.detailData.isvNo }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col v-if="$hasAgentEnt()" :sm="12">
        <a-descriptions>
          <a-descriptions-item label="代理商号">
            {{ vdata.detailData.agentNo }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col v-if="$hasAgentEnt()" :sm="12">
        <a-descriptions>
          <a-descriptions-item label="顶级代理商号">
            {{ vdata.detailData.topAgentNo }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="接口名称">
            {{ vdata.detailData.ifName }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="支付接口代码">
            {{ vdata.detailData.ifCode }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-divider />

   
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="商户全称">
            {{ vdata.detailData.mchFullName }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="商户简称">
            {{ vdata.detailData.mchShortName }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="商户类型">
            {{ vdata.detailData.merchantType == 1?'小微':vdata.detailData.merchantType == 2?'个体':vdata.detailData.merchantType == 1?'企业':'其他' }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="进件状态">
            <a-tag v-if="vdata.detailData.state === 0" color="default"> 草稿 </a-tag>
            <a-tag v-if="vdata.detailData.state === 1" color="warning"> 审核中 </a-tag>
            <a-tag v-if="vdata.detailData.state === 2" color="success"> 进件成功 </a-tag>
            <a-tag v-if="vdata.detailData.state === 3" color="error"> 驳回待修改 </a-tag>
            <a-tag v-if="vdata.detailData.state === 4" color="processing"> 待验证 </a-tag>
            <a-tag v-if="vdata.detailData.state === 5" color="processing"> 待签约 </a-tag>
            <a-tag v-if="vdata.detailData.state === 6" color="success"> 签约完成 </a-tag>
            <a-tag v-if="vdata.detailData.state === 7" color="warning"> 等待系统预审核 </a-tag>
            <a-tag v-if="vdata.detailData.state === 8" color="error"> 预审核拒绝 </a-tag>
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="联系人姓名">
            {{ vdata.detailData.contactName }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="联系人手机号">
            {{ vdata.detailData.contactPhone }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="商户拓展员ID">
            {{ vdata.detailData.epUserId }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="进件来源">
            <span v-if="vdata.detailData.applyPageType == 'PLATFORM_WEB'">运营平台系统</span>
            <span v-else-if="vdata.detailData.applyPageType == 'AGENT_WEB'">代理商系统</span>
            <span v-else-if="vdata.detailData.applyPageType == 'AGENT_APP'">{{ $SYS_NAME_MAP.AGENT_APP }}APP</span>
            <span v-else-if="vdata.detailData.applyPageType == 'AGENT_LITE'">{{ $SYS_NAME_MAP.AGENT_APP }}小程序</span>
            <span v-else-if="vdata.detailData.applyPageType == 'MCH_WEB'">商户系统</span>
            <span v-else-if="vdata.detailData.applyPageType == 'MCH_APP'">{{ $SYS_NAME_MAP.MCH_APP }}APP</span>
            <span v-else-if="vdata.detailData.applyPageType == 'MCH_LITE'">{{ $SYS_NAME_MAP.MCH_APP }}小程序</span>
            <span v-else>{{ vdata.detailData.applyPageType || '' }}</span>
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="系统申请单号">
            {{ vdata.detailData.applyId }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="渠道申请单号">
            {{ vdata.detailData.channelApplyNo }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="渠道自定义商户号">
            {{ vdata.detailData.channelDiyMchNo }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="24">
        <span style="color: black;">渠道响应参数:</span>
        <a-form-item label="">
          <a-textarea
            v-model:value="vdata.detailData.succResParameter"
            disabled="disabled"
            style="height: 100px;color: black; margin-top: 10px;"
          />
        </a-form-item>
      </a-col>
      <a-col :sm="24">
        <span style="color: black;">渠道拓展参数1:</span>
        <a-form-item label="">
          <a-textarea
            v-model:value="vdata.detailData.channelVar1"
            disabled="disabled"
            style="height: 100px;color: black; margin-top: 10px;"
          />
        </a-form-item>
      </a-col>
      <a-col :sm="24">
        <span style="color: black;">渠道拓展参数2:</span>
        <a-form-item label="">
          <a-textarea
            v-model:value="vdata.detailData.channelVar2"
            disabled="disabled"
            style="height: 100px;color: black; margin-top: 10px;"
          />
        </a-form-item>
      </a-col>
      <a-col :sm="24">
        <span style="color: black;">响应提示信息:</span>
        <a-form-item label="">
          <a-textarea
            v-model:value="vdata.detailData.applyErrorInfo"
            disabled="disabled"
            style="height: 100px;color: black; margin-top: 10px;"
          />
        </a-form-item>
      </a-col>
    </a-row>
  </a-drawer>
</template>

<script lang="ts" setup>
import { API_URL_MCH_APPLYMENT_LIST, req } from '@/api/manage'
import {defineProps,reactive, getCurrentInstance} from 'vue'
const { $hasAgentEnt, $SYS_NAME_MAP } = getCurrentInstance()!.appContext.config.globalProperties
  const props = defineProps({
    callbackFunc: { type: Function,default:null }
  })

  const vdata:any = reactive({
      btnLoading: false,
      detailData: {}, // 数据对象
      recordId: null, // 更新对象ID
      visible: false, // 是否显示弹层/抽屉
  })

  function show (recordId) { // 弹层打开事件
    vdata.detailData = { 'state': 1, 'type': 1 } // 数据清空
    // if (this.$refs.infoFormModel !== undefined) {
    //   this.$refs.infoFormModel.resetFields()
    // }
    
    vdata.recordId = recordId
    req.getById(API_URL_MCH_APPLYMENT_LIST, recordId).then(res => {
      vdata.detailData = res
    })
    vdata.visible = true
  }
  function onClose () {
    vdata.visible = false
  }
defineExpose({
  show //抛出show函数给父组件
})
</script>
